/**
 * @file main.cpp
 * @brief Test the functionality of contingent-ff plan solver.
 * @date 2024-2-27
*/

#include <iostream>
#include <string>
#include <memory>
#include <filesystem>

#include "cont_ff_plan_solver/cont_ff_plan_solver.hpp"
#include "contbtsys_core/Utils.hpp"

int main(int argc, char** argv) {
    ContBTSys::ContFFPlanSolver solver;
    ContBTSys::RootPtr root = nullptr;

    // No pddl files input, use default test cases
    if (argc <= 1) {
        // get current directory path
        std::filesystem::path cur_dir = std::filesystem::current_path();

        // get the path of the domain and problem files
        std::string test_domain = cur_dir.string() + "/tests/blocks/domain.pddl";
        std::string test_problem = cur_dir.string() + "/tests/blocks/p3.pddl";

        std::cout << "Test domain file: " << test_domain << std::endl;
        std::cout << "Test problem file: " << test_problem << std::endl;

        // get the plan tree
        root = solver.getPlan(test_domain, test_problem);
    } else {
        // get the plan tree
        
        std::cout << "Domain file: " << argv[1] << std::endl;
        std::cout << "Problem file: " << argv[2] << std::endl;

        root = solver.getPlan(argv[1], argv[2]);
    }
    
    // print the plan tree
    if (root != nullptr) {
        std::cout << "Below are the generated plan tree: " << std::endl;
        ContBTSys::print_action_tree(root);
    } else {
        std::cout << "No plan found!" << std::endl;
    }
}

